package com.guosheng;

import java.util.HashMap;
import java.util.*;

public class Test {
    public static void main(String[] args) {
        int[] arr = new int[]{168, 173, 178, 189, 195, 200};
        arr = bubble(arr);
        Map<String, String> m = new HashMap();
        int min = arr[1] - arr[0];

        for (int i = 1; i < arr.length; i++) {
            if (arr[i] - arr[i - 1] <= min) {
                min = arr[i] - arr[i - 1];
                m.put("max", arr[i] + "," + arr[i - 1]);
            }
        }
        System.out.println(m.get("max").split(",")[1] + " " + m.get("max").split(",")[0]);
    }

    //获取范围内的数值并转化成整数
    //对数组进行升序的冒泡排序
    //最后只需要比较一轮即可，

    public static int[] bubble(int[] arr) {

        for (int i = 0; i < arr.length - 1; i++) {//外层循环控制排序趟数
            for (int j = 0; j < arr.length - 1 - i; j++) {//内层循环控制每一趟排序多少次
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        return arr;
    }

}
